﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ArgusLight.Fractals2D.ComplexFractalColoring
{
	public abstract class PeriodicColoring : Coloring
	{
		/// <summary>
		/// Type: <see cref="PeriodicColoringParameter"/>
		/// </summary>
		public override Fractals2D.ColoringParameter Parameter
		{
			get
			{
				return this._parameter;
			}
			set
			{
				if (value is PeriodicColoringParameter)
				{
					this._parameter = (PeriodicColoringParameter)value;
				}
			}
		}
		private PeriodicColoringParameter _parameter;
		protected new PeriodicColoringParameter parameter { get { return (PeriodicColoringParameter)this.Parameter; } }

		/// <summary>
		/// Type: <see cref="PeriodicColoringData"/>
		/// </summary>
		public override Fractals2D.ColoringData Data
		{
			get
			{
				return this._data;
			}
			protected set
			{
				if (value is PeriodicColoringData)
					this._data = (PeriodicColoringData)value;
			}
		}
		private PeriodicColoringData _data;
		protected new PeriodicColoringData data { get { return (PeriodicColoringData)this.Data; } }

		public PeriodicColoring()
		{
			this._parameter = PeriodicColoringParameter.Default;
		}

		protected abstract double GetFrequency();

		public override void Reset(FractalParameter fParameter)
		{
			base.Reset(fParameter);
			this.Data = new PeriodicColoringData(fParameter.PixelWidth, fParameter.PixelHeight);
		}

		public override Color GetColor(int x, int y)
		{
			if (this.parameter.AutoSetFrequency == true)
				this.parameter.Frequency = this.GetFrequency();

			return base.GetColor(x, y);
		}
	}
}
